Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
import-from-string
Advanced tools
Load module from string using require or import.
import.meta.url
npm install import-from-string
import { requireFromString, importFromString } from "import-from-string";
const cjs = requireFromString("module.exports = 'Hi World!'");
console.log(cjs); // Hi World!
const esm = await importFromString("export default 'Hello World!'");
console.log(esm.default); // Hello World!
const { requireFromString, importFromString } = require("import-from-string");
async function main() {
const cjs = requireFromString("module.exports = 'Hi World!'");
console.log(cjs); // Hi World!
const esm = await importFromString("export default 'Hello World!'");
console.log(esm.default); // Hello World!
}
main();
Type: string
The code to import.
Type: string
Default: {Date.now()}.js
The virtual file name of the code to import.
Type: string
Default: The directory where the function is called
The virtual directory to import the code into.
Type: TransformOptions
esbuild transform options.
Type: BuildOptions
esbuild options.
Type: boolean
Default: false
skip esbuild build.
Type: string
The code to import.
Type: string
Default: {Date.now()}.js
The virtual file name of the code to import.
Type: string
Default: The directory where the function is called
The virtual directory to import the code into.
Type: string[]
Default: []
An array of additional paths to append when resolving modules.
Type: string[]
Default: []
An array of additional paths to prepend when resolving modules.
MIT License © 2023-Present Condor Hero
FAQs
Load module from string using require or import.
We found that import-from-string demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.